var rows=document.querySelector(".lby-right")
var pagination1=document.querySelector('.pagination1');

 (async function(){
    //获取所有数据
    var txt=await PromiseAjax({
        url:'./php/lbe.php'
    })
    //把字符串转为数组对象
    var ar1=eval('('+txt+')');
    //创建分页器的参数对象
    var o1={
        pageInfo:{
            pagenum:1,
            pagesize:12,
            totalsize:ar1.length,
            totalpage:Math.ceil(ar1.length/12)
        }
    }
    //创建分页器的实例化对象
     new Pagination(pagination1,o1,(m)=>{
         
        //获取当前页所对应的数据
        var ar2=ar1.slice((m-1)*12,m*12)
        //拼接所有内容
        var str=''
        //遍历数组对象
        ar2.forEach(item=>{
            str+=`
            <li>
                    <div class="imgbox">
                        <a href="./xqy.html?id=${item.id}">
                        <img src="${item.src}">
                        <img src="${item.src}"> 
                    </a>
                    </div>
                    
                    <p>${item.name}</p>
                    <span>${item.price}</span>
                </li>
                `
        })
        //把拼接好的内容渲染到页面中
        rows.innerHTML=str
    })
})()

var mhcxbox=document.querySelector('.head-ww')
var btn=mhcxbox.querySelector("button")
var inp=mhcxbox.querySelector("input")
var tbody=mhcxbox.querySelector("tbody")
btn .onclick=function(){
    var v1=inp.value
    var xhr =new XMLHttpRequest()
    xhr.open("get",'./php/mhcx.php?value='+v1)
    xhr.send()
    xhr.onload=function(){
        if(xhr.status==200){
            var txt=xhr.responseText
            var ar1=eval('('+txt+')')
            var str=''
            ar1.forEach(item=>{
                str+=`
                <tr>
                <td>${item.id}</td>
                <td>${item.name}</td>
                <td>${item.price}</td>
            </tr>
                `
            })
            
         tbody.innerHTML=str
        }
    }
}